package aufgabe_2_test.try02;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

/**
 * a TableModel for displaying the Results of the calculation
 * @author J. Quenzel & R. Flaegel
 *
 */
public class ResultTableModel extends AbstractTableModel{
	
/**
 * reference to the list of results
 */
ArrayList<ResultObject> resultList;
	
	public ResultTableModel(ArrayList<ResultObject> resultList) {
		this.resultList = resultList;
	}

	@Override
	public int getColumnCount() {
		return 4;
	}

	@Override
	public int getRowCount() {
		return resultList.size();
	}

	@Override
	public Object getValueAt(int arg0, int arg1) {
		switch(arg1){
		case 0: return resultList.get(arg0).getN();
		case 1: return resultList.get(arg0).getFactors();
		case 2: return resultList.get(arg0).getSum_cpuTime();
		case 3: return resultList.get(arg0).getWall_cpuTime();
		default: return "undefiniert";
		}
	}
	
	@Override
	public String getColumnName(int column) {		
		switch (column) {
		case 0: return "Ausgangszahl";
		case 1: return "Faktoren";
		case 2: return "Gesamte CPU-Zeit";
		case 3: return "Wall Clock";
		default: return "undefinierte Spalte";
		}

	}

}
